#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int nums[2 * n + 1] = {0};
	int num;
	int left = 1, right;
	for(int i = 0; i < n; i++){
	    cin>>num;
	    nums[num] = 1;
	}
	int res = 0;
	while(left <= 2 * n && nums[left] != 1) left++;
	while(left <= 2 * n){
		right = left + 1;
		while(right <= 2 *n && nums[right] != 0) right++;
		if(right <= 2 * n){
			res++;
			nums[right] = -1;
			nums[left] = -1;
		}else{
			break;
		}
		while(left <= 2 * n && nums[left] != 1) left++;
	}
	cout<<res;
	return 0;
}
